<template>
	<view>
		<view v-for="(item, index) in datalist" :key="index" style="margin: 10rpx;">
			<cardviewtext
				:title="item.title"
				:isTop="item.isTop"
				:author="item.author"
				:comments="item.comments"
				:time="item.time"
				:images="item.imagelist"
				@click="onCustomViewClick()"
			>
				<template v-slot:tips>
					<view class="slotcontent" v-if="item.showSearch">
						<text>搜索：</text>
						<view class="borderbox"><text>今日金价</text></view>
						<view class="borderbox"><text>精选好物</text></view>
					</view>
				</template>
			</cardviewtext>
		</view>
	</view>
</template>

<script>
	import cardviewtext from "../../../components/cardviewtext.vue"
	
	import newsData from "../../../Data/news.json"
	
	export default {
		components: {
			cardviewtext
		},
		data() {
			return {
			
				datalist: newsData
			}
		},
		methods: {
			onCustomViewClick() {
				console.log("卡片被点击了");
			}
		}
	}
</script>

<style>
	.slotcontent {
		margin: 10rpx 0;
		display: flex;
		align-items: center;
		font-size: 28rpx;
	}
	.slotcontent text {
		color: blue;
		margin-right: 10rpx;
	}
	.borderbox {
		border: 1rpx solid gray;
		border-radius: 10rpx;
		margin: 0 8rpx;
		padding: 0 10rpx; 
	}
</style>